<template>
  <h1>姓名：{{userInfo.name}}</h1>
  <h1>年龄：{{NewAge}}</h1>
  <button @click="changeName()">修改名称为：陈二狗</button>
</template>
<script>
	export default {
		computed:{
			name(){
				return this.$store.state.name
			},
			userInfo(){
				return this.$store.state.userInfo
			},
			NewAge(){
				return this.$store.getters.userInfoNewAge
			}
		},
		methods:{
			changeName(){
				this.$store.dispatch('changeName','陈二狗')
				this.$store.commit('userInfo',{name:'陈二狗',age:22})
			}
		}
	}
</script>
